<?php

/**
* @current fronteffectlibrary.php
* @author   LiuYang <liu_yang@haibao.com>
* @date 2016年8月1日 下午2:35:22
*/

namespace haibao\cms\business;

use haibao\cms\data\FrontEffectLibrary as FrontEffectLibraryyData;

class FrontEffectLibrary extends \haibao\cms\business\Base{
	
    public static function getFrontEffectLibraryList($Filter,$isGetOne = true){
        $data = new FrontEffectLibraryyData();
        if($isGetOne){
            return $data->getOne($Filter);
        }else{
            return $data->getAll($Filter);
        }
    }
    
    public static function delFrontEffectById($id,$arrSet){
        if(!$id){
            throw new BusinessException('Id不能为空！');
        }
        $data = new FrontEffectLibraryyData();
        $data->updateById($id, $arrSet);
    }
    
    public static function getfrontEffectListById($id){
        if(!$id){
            throw new BusinessException('Id不能为空！');
        }
        $data = new FrontEffectLibraryyData();
        return $data->getOneById($id);
    }
    
    public static function editFrontEffectLibrary($model){
       self::checkFrontEffectLibraryModel($model);
       $data = new FrontEffectLibraryyData();
       $data->editFrontEffectLibrary($model);
    }
    
    public static function addFrontEffectLibrary($model){
        self::checkFrontEffectLibraryModel($model);
        $data = new FrontEffectLibraryyData();
        $data->addFrontEffectLibrary($model);
    }
    
    private static function checkFrontEffectLibraryModel($model){
        
        if(!$model->EffectTitle){
            throw new BusinessException('EffectTitle不能为空！');
        }
        if(!$model->EffectUrl){
            throw new BusinessException('EffectUrl不能为空！');
        }
        if(!$model->EffectDesc){
            throw new BusinessException('EffectDesc不能为空！');
        }
        if(!$model->EffectKeywords){
            throw new BusinessException('EffectKeywords不能为空！');
        }
    }
}
